package cn.net.ecode.modules.msg.task.impl;

import cn.net.ecode.common.service.BaseService;
import cn.net.ecode.common.utils.SendMailUtil;
import cn.net.ecode.modules.msg.entity.MessageRecord;
import cn.net.ecode.modules.msg.task.MsgSendService;

/**
 * 消息发送服务（邮件实现）
 * @author ThinkGem
 * @version 2015-10-8
 */
public class EmailSendService extends BaseService implements MsgSendService {
	
	@Override
	public boolean sendMessage(MessageRecord mr) {
		
		try {

			SendMailUtil.sendEmail(mr.getReceiver(), mr.getMessage().getContentTitle(),
					mr.getMessage().getContentText());
			
			logger.info("发送邮件： " + mr.getReceiver() + "(" + mr.getReceiverName() + "), 内容：" 
					+ mr.getMessage().getContentText());
			
			return true;
		} catch (Exception ex) {
			logger.error("发送邮件异常：", ex);
		}
		
		return false;
	}

}
